# -*- coding:utf8 -*- #
# -----------------------------------------------------------------------------------
# ProjectName:  smalleel-hvac-iot-test
# FileName:     hvac_control.py
# Author  :
# Datetime:     2023/5/24 11:18
# Description：
# -----------------------------------------------------------------------------------
from common.util.configUtil.configUtil import ConfigUtil
from common.util.requestsUtil.requestsUtil import RequestsUtil
from core.mqtt.command.command_set import *

conf = ConfigUtil()
req = RequestsUtil()


def vrv_command_control(deviceNo=None, addrList=None, controlType: int = 3):
    """

    :param deviceNo:
    :param addrList: 批量控制的设备地址
    :param controlType:
                   1 异步控制单个设备
                   2 设备指令同步下发
                   3 批量异步控制
                   4 异步控制基站
                   5 更新采样周期 - 同步
    :return:
    """
    # deviceNo = conf.get_mqtt_config("deviceName")
    url = conf.get_control_command_url(controlType)
    print(url)
    if controlType == 3:
        params = vrv_asyncBatch_params(deviceNo, addrList)
    elif controlType == 4:
        params = collector_control_params(deviceNo)
    elif controlType == 5:
        params = collectro_cycle_params(deviceNo)
    elif controlType == 6:
        params = get_relation_params(deviceNo)
    else:
        params = vrv_control_params(deviceNo, addrList)
    print(params)
    if controlType == 3:
        res = req.send_request("post", url, params=params, parameterFormat="json")
    else:
        res = req.send_request("get", url, params=params, parameterFormat="data")
    print(res)


if __name__ == '__main__':
    addr = "V102305002014004402"
    vrv_command_control("V10230500201",addrList=addr, controlType=1)
